if("${CMAKE_GENERATOR}" MATCHES "Xcode")
  set(GLOBAL_XCODE_PROPERTIES
    XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++0x"
    XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++"
    XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME NO
    XCODE_ATTRIBUTE_CLANG_WARN_IMPLICIT_SIGN_CONVERSION YES
    XCODE_ATTRIBUTE_CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION YES
    XCODE_ATTRIBUTE_CLANG_WARN__EXIT_TIME_DESTRUCTORS NO
    XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "gnu99"
    XCODE_ATTRIBUTE_GCC_ENABLE_OBJC_EXCEPTIONS NO
    XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES
    XCODE_ATTRIBUTE_GCC_STRICT_ALIASING YES
    XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES
    XCODE_ATTRIBUTE_GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS YES
    XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION YES
    XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE YES
    XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE YES
    XCODE_ATTRIBUTE_GCC_WARN_FOUR_CHARACTER_CONSTANTS YES
    XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS YES
    XCODE_ATTRIBUTE_GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED YES
    XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR YES
    XCODE_ATTRIBUTE_GCC_WARN_PEDANTIC YES
    XCODE_ATTRIBUTE_GCC_WARN_SHADOW YES
    XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE YES
    XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS YES
    XCODE_ATTRIBUTE_GCC_WARN_UNUSED_PARAMETER YES
    XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE YES
    XCODE_ATTRIBUTE_WARNING_CFLAGS "-Wall -Wextra"
  )
  if(NOT DEFINED OVERRIDE_DONE)
    set(OVERRIDE_DONE 1)
    function(add_executable TARGET)
      _add_executable(${TARGET} ${ARGN})
      set_target_properties(${TARGET} PROPERTIES ${GLOBAL_XCODE_PROPERTIES})
    endfunction()
    function(add_library TARGET)
      _add_library(${TARGET} ${ARGN})
      set_target_properties(${TARGET} PROPERTIES ${GLOBAL_XCODE_PROPERTIES})
    endfunction()
  endif()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  set(CMAKE_BUILD_TYPE_INIT "Debug")
  set(FLAGS_C "-fvisibility=hidden -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors")
  set(FLAGS_CXX "${FLAGS_C} -Woverloaded-virtual -fvisibility-inlines-hidden")
  set(CMAKE_C_FLAGS_INIT "-std=gnu99 ${FLAGS_C} ${CMAKE_C_FLAGS_INIT}")
  set(CMAKE_CXX_FLAGS_INIT "-std=gnu++11 ${FLAGS_CXX} ${CMAKE_CXX_FLAGS_INIT}")
endif()
